package com.company.huisuo.biz.dialog

import android.app.Activity
import android.view.WindowManager
import androidx.core.widget.addTextChangedListener
import com.company.huisuo.R
import com.company.huisuo.base.BaseCenterPopupView
import com.company.huisuo.databinding.DialogFeedBackInputBinding


class FeedBackInputDialog(activity: Activity) : BaseCenterPopupView<DialogFeedBackInputBinding>(
    activity
) {
    override val getLayoutId: Int
        get() = R.layout.dialog_feed_back_input
    override val getViewBinding: DialogFeedBackInputBinding
        get() = DialogFeedBackInputBinding.bind(contentView)

    override fun initData() {
        // 阻止软键盘自动弹出
        dialog?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)

        mBinding.ivClose.setOnClickListener {
            dismiss()
        }
        mBinding.etInput.addTextChangedListener {
            val length = mBinding.etInput.text?.toString()?.length ?: 0
            mBinding.tvNumber.text = "${length}/100"
        }
        mBinding.tvOk.setOnClickListener {
            dismiss()
        }
    }
}